using UnityEngine;
using System.Collections;

public class readyButton : MonoBehaviour {

	public CCText text;
	private bool isActivated=false;
	private OnMouseClicReadyDelegate onMouseClicMethod;
	
	public bool IsActivated
	{
		get { return isActivated; }
	}
	
	void Start()
	{
		isActivated = false;	
	}
	
	public void initializeReadyButton(OnMouseClicReadyDelegate fctClic)
	{
		onMouseClicMethod = fctClic;
		isActivated = false;
	}
	
	public void ActiveButton(bool active)
	{
		isActivated=active;
		this.collider.enabled=!active;
		if ( active )
		{
			this.renderer.material.color = Color.green;
			text.Color = Color.white;
		}
		else
		{
			//this.renderer.material.color = Color.white;
			//text.Color = Color.black;
		}
	}
	
	void OnMouseUpAsButton ()
	{
		onMouseClicMethod();
	}
	
	void Update()
	{
		if ( !isActivated )
		{
			text.Color = new Color(Mathf.PingPong(1, Time.time),Mathf.PingPong(1, Time.time), Mathf.PingPong(1, Time.time));
		}
	}
	
}
